home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_097 / splines / spline.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  80 lines

  1. /* The routines in this file are copyright (c) 1987 by Helene (Lee) Taran.
  2.  * Permission is granted for use and free distribution as long as the
  3.  * original author's name is included with the code.
  4.  */
  5.  
  6. #include "spline.h"
  7.  
  8. extern struct Window *Window;
  9. extern struct Screen *Screen;
  10. extern struct PopUp_Menu CurveMenu, PointMenu;
  11. DLIST_ELEMENT Control_Points;
  12.  
  13. main()
  14.  
  15.   OpenLibraries();
  16.   SetupEnvironment();
  17.   Init_List(&Control_Points);
  18.   Create_ControlPoints();
  19.   Init_GValues();  /* sets up the Gvalues for interpolating splines */
  20.   while(1)  /* Main Loop */
  21.      { struct IntuiMessage *message, *GetMsg();
  22.        struct IntuiMessage mcopy;
  23.  
  24.        /* Wait until something happens and then respond to it */
  25.        Wait(1 << Window->UserPort->mp_SigBit); 
  26.        
  27.        /* Now, one or more input events have arrived. Respond to ALL */
  28.        while (message = GetMsg(Window->UserPort))
  29.           {
  30.             mcopy = *message;         /* make a copy of the message */
  31.             ReplyMsg(message);        /* reply to it immediately */
  32.             ProcessMessage(&mcopy);   /* react to the message */
  33.            }
  34.     }
  35. }
  36.  
  37.  
  38. /* ProcessMessage processes an input event given */ 
  39. ProcessMessage(msg)
  40. struct IntuiMessage *msg;
  41. {
  42.   switch (msg->Class) {
  43.     case CLOSEWINDOW  :  close_things(); exit(0);
  44.     case MOUSEBUTTONS : 
  45.       if (msg->Code == SELECTDOWN) {
  46.          DLISTPTR p,Select_ControlPoint();
  47.            if (p = Select_ControlPoint(msg->MouseX,msg->MouseY)) 
  48.               Edit_ControlPoint(Window,p);
  49.            else Edit_CurveStyle(Window);
  50.            }
  51.       break;
  52.    }
  53.  
  54.  
  55. Create_ControlPoints()
  56. {
  57.   DLISTPTR p; void *calloc();
  58.   REAL_POINT *c;
  59.   
  60.   p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT));
  61.   c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT));
  62.   c->x = 300;  c->y = 200;  p->contents = c;
  63.   INSERT_FIRST(p,&Control_Points);
  64.  
  65.   p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT));
  66.   c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT));
  67.   c->x = 155;  c->y = 30;  p->contents = c;
  68.   INSERT_FIRST(p,&Control_Points);
  69.  
  70.   p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT));
  71.   c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT));
  72.   c->x = 20;  c->y = 175;  p->contents = c;
  73.   INSERT_FIRST(p,&Control_Points);
  74.  
  75.   Draw_ControlPoints(Window);
  76.   Draw_Natural_Bspline(Window,&Control_Points);
  77. }
  78.